package com.code.juc.lock;

public class VolatileDemo {

    private static volatile boolean flag = false;

    public static void main(String[] args) throws Exception {
        new Thread(() -> {
            while (!flag) {
                System.out.println("异步线程running...");
            }
        }).start();

        Thread.sleep(2000);
        flag = true;

    }
}
